﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TMV.Report
{
	public class MyXML
	{
		public static byte[]? GetXMLData(汽车衡接口信息 real)
		{
			if (real == null) return null;
			var memoryStream = new MemoryStream();
			System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(real.GetType());

			using (var streamWriter = new StreamWriter(memoryStream, Encoding.GetEncoding("GBK")))
			{
				x.Serialize(streamWriter, real);
				memoryStream.Seek(0, SeekOrigin.Begin);
				var streamReader = new StreamReader(memoryStream, Encoding.GetEncoding("GBK"));
				var gbkEncodedXml = streamReader.ReadToEnd();
				return MyDES.DESEncrypt(gbkEncodedXml);
			}
		}
	}
}
